package com.xiaolin.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaolin.admin.entity.User;
import com.xiaolin.admin.mapper.UserMapper;
import com.xiaolin.admin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author xiaolin
 * @since 2024-04-27
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getAllUsers() {
        return userMapper.getAllUsers();
    }

    @Override
    public PageInfo<User> getUserPage(Integer page, Integer pageSize) {
        // 分页参数设置
        PageHelper.startPage(page, pageSize);
        List<User> users = getAllUsers();
        // 分页结果集封装
        return new PageInfo<>(users);
    }
}
